//
//  HomeModel.m
//  VEW
//
//  Created by lanou3g on 15/7/17.
//  Copyright (c) 2015年 Y团. All rights reserved.
//

#import "HomeModel.h"
#import "ImageDownloader.h"
@implementation HomeModel


- (void)stratDownImage {
    
    ImageDownloader *loader = [[ImageDownloader alloc] init];
    [loader requestImageURLString:self.z_image successBlock:^(NSData *data) {
        self.coverImage = [UIImage imageWithData:data];
        
        NSArray *cachesArray = NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES);
        NSString *cachPath = [cachesArray lastObject];
        NSString *folderPath = [cachPath stringByAppendingPathComponent:@"Download"];
        
        NSString *imagePath = [folderPath stringByAppendingPathComponent:[[self.z_image stringByReplacingOccurrencesOfString:@"/" withString:@"_"] substringFromIndex:5]];
        [data writeToFile:imagePath atomically:YES];
        
    } errorBolck:^(NSError *error) {
        
    }];
}

+ (instancetype)newsModelWithDict:(NSDictionary *)dict
{
    HomeModel *model = [[self alloc]init];
    
    [model setValuesForKeysWithDictionary:dict];
    
    return model;
}



@end
